#include "PDFManager.h"
#include "TextGenerator.h"
#include "const.h"

const char *FONT_PATH = "/usr/share/fonts/truetype/custom/SIMSUN.ttf";
const char *OUTPUT_FILE = "output.pdf";

int main() {
    try {
        PDFManager pdfmanager;
        // 加载宋体
        pdfmanager.loadFont(FONT_PATH);

        // 生成文字 0x4E00~0x9FFF是Unicode常用中文的范围
        auto all_chars = TextGenerator::start(0x4E00, 0x9FFF);

        // 写入
        size_t i = 0;
        for (; i < all_chars.size(); i += CHARS_PER_PAGE) {
            pdfmanager.addTextPage(all_chars, i, CHARS_PER_PAGE);
        }

        pdfmanager.saveToFile(OUTPUT_FILE);
        std::cout << "PDF successfully created as " << OUTPUT_FILE << std::endl;

    } catch (const std::exception &e) {
        std::cerr << e.what() << '\n';
        return 1;
    }

    return 0;
}
